<?php
class Library_Model_CommentMapper extends Library_Model_DomainObjectAbstract
{
	private static $_instance = null;
	public function searchById($id){
		
	}
	public function searchByBookId($id){
		$db = $this->getDb();
		$commentSelect = $db->select()
							->from('book_comment')
							->join('users'.'user.id = book_comments.user_id')
							->where('book_id = ?',$id );
		$comments = $db->fetchAll($commentSelect);
		
		$commentArray = array();
		foreach($comments as $comment){
			$commentObj = new Library_Model_Comment();
			$commentObj->setId($comment['comment_id'])
						//->setBook($)
						->setComment($comment['comment'])
						->setUser($comments['username']);
			$commentArray[] = $commentObj;
		}
		return $commentArray;
	}
	public function searchByUserId($id){
		
	}	
	protected function _populate($data){
		
	}
	protected function _insert(Library_Model_DomainObjectAbstract $obj){
		
	}
	protected function _update(Library_Model_DomainObjectAbstract $obj){
		
	}
	/* 
	@return Library_Model_CommentMapper
	 */
	
	public static function getInstance(){
		if(is_null(self::$_instance)){
			$c = __CLASS__;
			self::$_instance = new $c;
		}
		return self::$_instance;
	}
}